"""
    2011 Boris Tatarintsev
    
    Simple AABB class
"""

class AABB:

    def __init__(self, x1 = 0, y1 = 0, x2 = 0, y2 = 0):
        self.__reinit(x1, y1, x2, y2)
    
    def __reinit(self, x1, y1, x2, y2):
        self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
        self.ox = x1 + (x2 - x1) / 2
        self.oy = y1 + (y2 - y1) / 2
        self.half_width = self.ox - x1
        self.half_height = self.oy - y1
    
    def __str__(self):
        output = "x1: " + str(self.x1) + ", y1: " + str(self.y1) + \
        "\nx2: " + str(self.x2) + ", y2: " + str(self.y2) + "\n"
        return output
    
    def reset(self):
        self.x1, self.y1, self.x2, self.y2 = 0, 0, 0, 0
        self.ox, self.oy = 0, 0
        self.half_width, self.half_height = 0, 0
    
    def getArea(self):
        return 4 * self.half_width * self.half_height